package tugas.akhir.jason;

import tugas.akhir.jason.dr5_kategorikerusakan;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

public class dr4_penyebabkerusakan extends Activity{

	private String labelId, labelAlamat;
	private Button simpan;
	private CheckBox dr4cbx_gempabumi;
	private CheckBox dr4cbx_tsunami;
	private CheckBox dr4cbx_gunungmeletus;
	private CheckBox dr4cbx_banjir;
	private CheckBox dr4cbx_kebakaran;
	private CheckBox dr4cbx_angintopan;
	private CheckBox dr4cbx_tanahlongsor;
	private CheckBox dr4cbx_lainlain;
	Button next_button5;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dr4_penyebabkerusakan);
        
        TextView rid = (TextView) findViewById (R.id.dr3_reportid_label);
        labelId = "ID Laporan: " + variabelstatis.idglobal;
        rid.setText (labelId);
        

        //alamat
        TextView address = (TextView) findViewById (R.id.dr3_address_label);
        labelAlamat = "Alamat: " + variabelstatis.alamatglobal;
        address.setText (labelAlamat);   
        
        simpan = (Button)this.findViewById(R.id.next_button5);
        simpan.setOnClickListener(onSave);
        
        dr4cbx_gempabumi = (CheckBox)this.findViewById(R.id.dr4cbx_gempabumi);
        dr4cbx_tsunami = (CheckBox)this.findViewById(R.id.dr4cbx_tsunami);
        dr4cbx_gunungmeletus = (CheckBox)this.findViewById(R.id.dr4cbx_gunungmeletus);
        dr4cbx_banjir = (CheckBox)this.findViewById(R.id.dr4cbx_banjir);
        dr4cbx_kebakaran = (CheckBox)this.findViewById(R.id.dr4cbx_kebakaran);
        dr4cbx_angintopan = (CheckBox)this.findViewById(R.id.dr4cbx_angintopan);
        dr4cbx_tanahlongsor = (CheckBox)this.findViewById(R.id.dr4cbx_tanahlongsor);
        dr4cbx_lainlain = (CheckBox)this.findViewById(R.id.dr4cbx_lainlain);
	
     
		Intent i = getIntent();
		if (i.getIntExtra("variablestatis.dr4_gempabumi",0)==1){
			dr4cbx_gempabumi.setChecked(true);
		}else{dr4cbx_gempabumi.setChecked(false);}
		
		if (i.getIntExtra("variablestatis.dr4_tsunami",0)==1){
			dr4cbx_tsunami.setChecked(true);
		}else{dr4cbx_tsunami.setChecked(false);}
		
		if (i.getIntExtra("variablestatis.dr4_gunungmeletus",0)==1){
			dr4cbx_gunungmeletus.setChecked(true);
		}else{dr4cbx_gunungmeletus.setChecked(false);}
		
		if (i.getIntExtra("variablestatis.dr4_banjir",0)==1){
			dr4cbx_banjir.setChecked(true);
		}else{dr4cbx_banjir.setChecked(false);}
		
		if (i.getIntExtra("variablestatis.dr4_kebakaran",0)==1){
			dr4cbx_kebakaran.setChecked(true);
		}else{dr4cbx_kebakaran.setChecked(false);}
		
		if (i.getIntExtra("variablestatis.dr4_angintopan",0)==1){
			dr4cbx_angintopan.setChecked(true);
		}else{dr4cbx_angintopan.setChecked(false);}
		
		if (i.getIntExtra("variablestatis.dr4_tanahlongsor",0)==1){
			dr4cbx_tanahlongsor.setChecked(true);
		}else{dr4cbx_tanahlongsor.setChecked(false);}
		
		if (i.getIntExtra("variablestatis.dr4_lainlain",0)==1){
			dr4cbx_lainlain.setChecked(true);
		}else{dr4cbx_lainlain.setChecked(false);}
	}  
		
	private View.OnClickListener onSave=new View.OnClickListener() {
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.next_button5:
			
			if (dr4cbx_gempabumi.isChecked()) variabelstatis.dr4_gempabumi=" Gempa Bumi; "; else variabelstatis.dr4_gempabumi="";
			if (dr4cbx_tsunami.isChecked()) variabelstatis.dr4_tsunami=" Tsunami; "; else variabelstatis.dr4_tsunami="";
			if (dr4cbx_gunungmeletus.isChecked()) variabelstatis.dr4_gunungmeletus=" Gunung Meletus; "; else variabelstatis.dr4_gunungmeletus="";
			if (dr4cbx_banjir.isChecked()) variabelstatis.dr4_banjir=" Banjir; "; else variabelstatis.dr4_banjir="";
			if (dr4cbx_kebakaran.isChecked()) variabelstatis.dr4_kebakaran=" Kebakaran; "; else variabelstatis.dr4_kebakaran="";
			if (dr4cbx_angintopan.isChecked()) variabelstatis.dr4_angintopan=" Angin Topan; "; else variabelstatis.dr4_angintopan="";
			if (dr4cbx_tanahlongsor.isChecked()) variabelstatis.dr4_tanahlongsor=" Tanah Longsor; "; else variabelstatis.dr4_tanahlongsor="";
			if (dr4cbx_lainlain.isChecked()) variabelstatis.dr4_lainlain=" lain-lain; "; else variabelstatis.dr4_lainlain="";
			variabelstatis.dr4_penyebabkerusakan = "" + variabelstatis.dr4_gempabumi + variabelstatis.dr4_tsunami + variabelstatis.dr4_gunungmeletus + variabelstatis.dr4_banjir + variabelstatis.dr4_kebakaran + variabelstatis.dr4_angintopan + variabelstatis.dr4_tanahlongsor + variabelstatis.dr4_lainlain ;
			}
			
			{ startActivity(new Intent(dr4_penyebabkerusakan.this,dr5_kategorikerusakan.class)); }	
		}
	};
}